Break Beam Sensor

The break beam sensor can be used to detect an object entering a specific place.

Use it to detect vehicles crossing a line, intruders in your space, and much more!


Tutorial

Watch this video for a complete tutorial:

Quick Reference

Wiring

Position the IR LED and the IR sensor so they face each other:

Facing

Wire up as follows, using the Edge Connector or Motor Controller board:

Sensor Microbit
Sensor (with 3 wires) P13
LED (with 2 wires) Any GND and 3V3 pins, e.g on P7
Wiring

You don't have to use pin P13. You can use any digital pin. Just remember to adjust your code accordingly.

Coding

Enter this code in on start:

Code 1

Enter this code in forever:

Code 2

Download the code to the microbit.

Test with the beam unbroken (you should see a cross) and broken (you should see a tick):

Break beam sensor

Note: Using the sensor in bright sunlight can lead to false readings.